package cn.kgc.controller;

import cn.kgc.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 东海龙王
 * @version 1.0
 * @date 2023/2/23 - 15:22
 */
@Controller
public class SecondController {

    @RequestMapping("/showIndex")
    public String showIndex(Model model){
        model.addAttribute("hello","hello-thymeleaf");
        return "index";
    }

    @RequestMapping("/qqq")
    public ModelAndView showStudent(){
        ModelAndView modelAndView=new ModelAndView();
        Student student=new Student("zs",23,"男");
        Student student2=new Student("zs",25,"女");
        Student student3=new Student("zs",88,"男");
        List<Student>list=new ArrayList<Student>();
        list.add(student);
        list.add(student2);
        list.add(student3);
        modelAndView.addObject("listStudents",list);
        modelAndView.setViewName("Student");    //设置跳转页面的名称
        return modelAndView;
    }
        @RequestMapping("/showText")
    public String showText(Model model){
        model.addAttribute("showtext", "<span style='color:red'>测试颜色</span>");

        return "text";
    }
}
